//
//  LPActivityCouseStudyClassTableViewCell.m
//  LovingPartyBuilding
//
//  Created by 刘应平 on 2017/6/9.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "LPActivityCouseStudyClassTableViewCell.h"

@interface LPActivityCouseStudyClassTableViewCell ()

/** backView  */
@property (strong, nonatomic) UIView  *backView;

/**  图片   */
@property (strong, nonatomic) UIImageView  *actImageView;
/**  标题  */
@property (strong, nonatomic) UILabel  *actLabel;
/**  时间  */
@property (strong, nonatomic) UILabel  *timeLabel;
/**  评分  */
@property (strong, nonatomic) UILabel  *scoreLabel;

/**  underLin  */
@property (strong, nonatomic) UILabel  *studLinklabel;
/** 箭头图片  */
@property (strong, nonatomic) UIButton  *arrowsImageVIew;


@end
@implementation LPActivityCouseStudyClassTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


/**  默认高度170  现在120 ，因为没有加排行*/
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self layoutUI];
    }
    return self;
}




#pragma mark - 界面
- (void)layoutUI{
    [self addSubview:self.backView];
    [self.backView addSubview:self.actImageView];
    [self.backView addSubview:self.scoreLabel];
    [self.backView addSubview:self.timeLabel];
    [self.backView addSubview:self.actLabel];
//    [self addSubview:self.studLinklabel];
    
    
    self.backView.sd_layout
    .topSpaceToView(self,10 * [UIScreen zj_screenHScale])
    .leftEqualToView(self)
    .heightIs(100 * [UIScreen zj_screenHScale])
    .widthIs([UIScreen zj_screenWith]);
    
    self.actImageView.sd_layout
    .topEqualToView(self.backView)
    .leftSpaceToView(self.backView,12 * [UIScreen zj_screenWScale])
    .heightIs(100 * [UIScreen zj_screenHScale])
    .widthIs(120 * [UIScreen zj_screenWScale]);
    
    
    self.scoreLabel.sd_layout
    .bottomEqualToView(self.actImageView)
    .leftSpaceToView(self.actImageView, 10 * [UIScreen zj_screenWScale])
    .heightIs(12 * [UIScreen zj_screenHScale])
    .widthIs([UIScreen zj_screenWith] - 154 * [UIScreen zj_screenWScale]);
    
    self.timeLabel.sd_layout
    .bottomSpaceToView(self.scoreLabel, 10 * [UIScreen zj_screenHScale])
    .leftEqualToView(self.scoreLabel)
    .heightIs(12 * [UIScreen zj_screenHScale])
    .widthIs([UIScreen zj_screenWith] - 154 * [UIScreen zj_screenWScale]);
    
    self.actLabel.sd_layout
    .topEqualToView(self.actImageView)
    .leftEqualToView(self.scoreLabel)
    .heightIs(66 * [UIScreen zj_screenHScale])
    .widthIs([UIScreen zj_screenWith] - 154 * [UIScreen zj_screenWScale]);


    self.studLinklabel.sd_layout
    .topSpaceToView(self.backView, 10 * [UIScreen zj_screenHScale])
    .leftEqualToView(self)
    .heightIs(40 * [UIScreen zj_screenHScale])
    .widthIs([UIScreen zj_screenWith]);
    
    [self.studLinklabel addSubview:self.arrowsImageVIew];
    self.arrowsImageVIew.sd_layout
    .centerYEqualToView(self.studLinklabel)
    .rightSpaceToView(self.studLinklabel, 20 * [UIScreen zj_screenWScale])
    .heightIs(20 * [UIScreen zj_screenHScale])
    .widthIs(20 * [UIScreen zj_screenHScale]);
    
    
    
    TenGrayShadowView *ten = [TenGrayShadowView new];
    [self addSubview:ten];
    ten.sd_layout.bottomEqualToView(self)
    .leftEqualToView(self)
    .rightEqualToView(self)
    .heightIs(10 * [UIScreen zj_screenHScale]);
    
}


#pragma mark - 私有方法
//- (void)setModel:(ActivityJoinDetailModel *)model{
//    _model = model;
//    
//    [self.actImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",BASEIMAGEURL,model.COVER_JSON[0][@"file_path"]]] placeholderImage:PlaceholderImage];
//    if (model.SIGN_NUM.length == 0) {
//        self.numberLabel.text = [NSString stringWithFormat:@"已报名%@人",@"0"];
//    }else{
//        self.numberLabel.text = [NSString stringWithFormat:@"已报名%@人",model.SIGN_NUM];
//    }
//    self.typeLabel.text = model.TAGS_NAMES;
//    if (model.ADDRESS.length == 0) {
//        self.addressLabel.text = @"暂无";
//    }else{
//        self.addressLabel.text = model.ADDRESS;
//    }
//    if (model.START_TIME.length == 0) {
//        self.timeLabel.text = @"待定";
//    }else{
//        self.timeLabel.text = model.START_TIME;
//    }
//    
//    CGFloat height;
//    if (model.HEIGHT < 60 * [UIScreen zj_screenHScale]) {
//        height = model.HEIGHT;
//    }else{
//        height = 60 * [UIScreen zj_screenHScale];
//    }
//    
//    
//    self.actLabel.sd_layout
//    .topEqualToView(self.actImageView)
//    .leftEqualToView(self.addressImageView)
//    .heightIs(height)
//    .widthIs([UIScreen zj_screenWith] - 172 * [UIScreen zj_screenWScale]);
//    self.actLabel.attributedText = [UILabel setSpaceForLineWithText:model.DESCRIPTION lineSpace:6 * [UIScreen zj_screenHScale]];
//}

/**  学习排行的点击事件  */
- (void)tapClick{
    if (self.arrowsImageVIew.selected) {
        self.arrowsImageVIew.selected = NO;
    }else{
        self.arrowsImageVIew.selected = YES;
    }
    
    if (self.delegate) {
        [self.delegate lpActivityCouseStudyClassWithCell:self isClickFlod:self.arrowsImageVIew.isSelected row:self.cellRow];
    }
    

}

/**  课程的点击事件  */
- (void)tapBackView{
    if (self.delegate) {
        [self.delegate lpActivityCouseStudyClassWithCell:self row:self.cellRow];
    }
}

#pragma mark - getter
- (UIView *)backView{
    if (!_backView) {
        _backView = [UIView new];
        _backView.userInteractionEnabled = YES;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapBackView)];
        [_backView addGestureRecognizer:tap];
    }
    return _backView;
}

- (UIButton *)arrowsImageVIew{
    if (!_arrowsImageVIew) {
        _arrowsImageVIew = [UIButton new];
        _arrowsImageVIew.imageView.contentMode = UIViewContentModeRight;
        [_arrowsImageVIew setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
        [_arrowsImageVIew setImage:[UIImage imageNamed:@""] forState:UIControlStateSelected];
        
    }
    return _arrowsImageVIew;
}


- (UIImageView *)actImageView{
    if (!_actImageView) {
        _actImageView = [UIImageView new];
    }
    return _actImageView;
}

- (UILabel *)timeLabel{
    if (!_timeLabel) {
        _timeLabel = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor textGrayColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = [UIFont systemFontOfSize:14 * [UIScreen zj_textFontScale]];
            label;
        });
    }
    return _timeLabel;
}



- (UILabel *)scoreLabel{
    if (!_scoreLabel) {
        _scoreLabel = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor textGrayColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = [UIFont systemFontOfSize:14 * [UIScreen zj_textFontScale]];
            label;
        });
    }
    return _scoreLabel;
}

- (UILabel *)actLabel{
    if (!_actLabel) {
        _actLabel = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor textBlackColor];
            label.numberOfLines = 0;
            label.backgroundColor = [UIColor clearColor];
            label.font = [UIFont systemFontOfSize:16 * [UIScreen zj_textFontScale]];
            label;
        });
    }
    return _actLabel;
}

- (UILabel *)studLinklabel{
    if (!_studLinklabel) {
        _studLinklabel = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentCenter;
            label.textColor = [UIColor textBlackColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = [UIFont systemFontOfSize:16 * [UIScreen zj_textFontScale]];
            label.layer.borderColor = [UIColor themeGrayColor].CGColor;
            label.layer.borderWidth = 1;
            label.userInteractionEnabled = YES;
            UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick)];
            [label addGestureRecognizer:tap];
            label;
        });
    }
    return _studLinklabel;
}


@end
